home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / C de cerca / Codewarrior Lite / MacOS Support / Headers / ANSI Headers / stat.h < prev    next >
Text File  |  1995-12-29  |  3KB  |  104 lines

  1. /*
  2.  *    File:        stat.h
  3.  *                ©1993-1995 metrowerks Inc. All rights reserved
  4.  *    Author:        Berardino E. Baratta
  5.  *
  6.  *    Content:    Interface file to standard UNIX-style entry points ...
  7.  *
  8.  *    NB:            This file implements some UNIX low level support.  These functions
  9.  *                are not guaranteed to be 100% conformant.
  10.  */
  11.  
  12. #ifndef    _STAT
  13. #define    _STAT
  14.  
  15. #ifndef _TIME
  16. #include <time.h>
  17. #endif
  18.  
  19. /*
  20.  *    Local typedefs for stat struct
  21.  */
  22. typedef unsigned long    mode_t;
  23. typedef unsigned long    ino_t;
  24. typedef unsigned long    dev_t;
  25. typedef short            nlink_t;
  26. typedef unsigned long    uid_t;
  27. typedef unsigned long    gid_t;
  28. typedef long            off_t;
  29.  
  30. #pragma options align=mac68k
  31.  
  32. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  33. #pragma import on
  34. #endif
  35.  
  36. /*
  37.  *    (stat) st_mode bit values (only ones relevant for the Mac)
  38.  *    NB: all modes marked as (GUSI) mean that the mode is used only by GUSI
  39.  *        (Grand Unified Sockets Interface).
  40.  */
  41. #define S_IFMT        0x0F00        /* type of file */
  42. #define   S_IFCHR    0x0200        /*   character special (GUSI) */
  43. #define   S_IFDIR    0x0400        /*   directory */
  44. #define   S_IFREG    0x0800        /*   regular */
  45. #define   S_IFLNK    0x0A00        /*   symbolic link */
  46. #define   S_IFSOCK    0x0E00        /*   socket (GUSI) */
  47.  
  48. /*
  49.  *    File type macros
  50.  */
  51. #define S_ISFIFO(m)    (((m)&(S_IFMT)) == (S_IFIFO))
  52. #define S_ISDIR(m)    (((m)&(S_IFMT)) == (S_IFDIR))
  53. #define S_ISCHR(m)    (((m)&(S_IFMT)) == (S_IFCHR))
  54. #define S_ISBLK(m)    (((m)&(S_IFMT)) == (S_IFBLK))
  55. #define S_ISREG(m)    (((m)&(S_IFMT)) == (S_IFREG))
  56.  
  57. struct stat
  58. {
  59.     mode_t        st_mode;        /* File mode; see #define's below */
  60.     ino_t        st_ino;            /* File serial number */
  61.     dev_t        st_dev;            /* ID of device containing this file */
  62.     nlink_t        st_nlink;        /* Number of links */
  63.     uid_t        st_uid;            /* User ID of the file's owner */
  64.     gid_t        st_gid;            /* Group ID of the file's group */
  65.     dev_t        st_rdev;        /* Device type */
  66.     off_t        st_size;        /* File size in bytes */
  67.     time_t        st_atime;        /* Time of last access */
  68.     time_t        st_mtime;        /* Time of last data modification */
  69.     time_t        st_ctime;        /* Time of last file status change */
  70.     long        st_blksize;        /* Optimal blocksize */
  71.     long        st_blocks;        /* blocks allocated for file */
  72. };
  73.  
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77.  
  78. /*
  79.  *    Get state information on a file.
  80.  */
  81. int stat(const char *path, struct stat *buf);
  82.  
  83. /*
  84.  *    Get state information on an open file.
  85.  */
  86. int fstat(int fildes, struct stat *buf);
  87.  
  88. /*
  89.  *    Create a directory (mode is ignored on the mac).
  90.  */
  91. int mkdir(const char *path, int mode);
  92.  
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96.  
  97. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  98. #pragma import reset
  99. #endif
  100.  
  101. #pragma options align=reset
  102.  
  103. #endif
  104.